package com.yoomiito.app.ui.my.teamallowance

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.yoomiito.app.R
import com.yoomiito.app.base.App
import com.yoomiito.app.base.BaseActivity
import com.yoomiito.app.model.my.TeamAllowance
import com.yoomiito.app.model.my.TeamAllowanceData
import kotlinx.android.synthetic.main.act_team_allowance.*
import kotlinx.android.synthetic.main.view_my_order_top.*

class TeamAllowanceActivity :BaseActivity<TeamAllowancePresenter>(){
    companion object{
        fun start(context: Context){
            val intent = Intent(context,TeamAllowanceActivity::class.java)
            context.startActivity(intent)
        }
    }

    private var mAdapter:TeamAllowanceAdapter = TeamAllowanceAdapter(null)
    override fun getLayoutId(): Int = R.layout.act_team_allowance

    override fun newP(): TeamAllowancePresenter = TeamAllowancePresenter(App.mAppConfig)

    override fun initData(savedInstanceState: Bundle?) {
        tv_title.setTitleStyle()
        tv_title.setCenterText("团队业绩")
        initRcy()
        p.getList()
    }

    private fun initRcy() {
        rcy.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
        rcy.adapter = mAdapter
    }

    fun setData(data:TeamAllowance?){
        tv_title_dec.text = "本月团队总业绩"
        tv_money.text = data?.allMoney
        tv_des.text = "数据仅供参考，实际业绩以结算为准"
//        val list = data?.list
//        list?.add(TeamAllowanceData(data?.teamAccount,"本月淘宝/优品预估管理津贴"))
        mAdapter.setNewData(data?.list)
    }
}